<template>
    <div>
        <table class="table table-bordered">
    <tr>
        <td>房号</td>
        <td>
            <input type="text" v-model="info.orderName">
        </td>
    </tr>
    <tr>
        <td>状态</td>
        <td>
            <input type="radio" v-model="info.orderStatus" :value=0>启用
            <input type="radio" v-model="info.orderStatus" :value=1>禁用
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="修改" @click="add" class="btn btn-primary">
        </td>
    </tr>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';

onMounted(()=>{
    fan();
})

let router=useRouter();
let route=useRoute();

let info=reactive({
    "id":route.query.id,
    "orderName": "",
  "orderStatus": 0,
});

const add=()=>{
axios({
    url:'https://localhost:7002/api/Order/UpOrder',
    data:info,
    method:'put'
})
.then(res=>{
    if(res.data>0){
alert('修改成功');
    }else{
        alert('修改失败')
    }
})
.catch(err=>{
    
})
}

const fan=()=>{
    axios({
        url:'https://localhost:7002/api/Order/GetOrderByid',
        params:{id:route.query.id},
        method:'get'
    })
    .then(res=>{
        info.orderName=res.data.orderName;
        info.orderStatus=res.data.orderStatus;
    })
}


</script>

<style scoped>

</style>